package org.zpmis.domain.role.vo;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.zpmis.domain.role.model.SysRole;

import javax.persistence.*;
import java.io.Serializable;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;

@Data
public class SysRoleListVo implements Serializable {
    /**
     * 主键id
     */
    private Long id;

    /**
     * 角色名
     */
    private String roleName;

    /**
     * 角色说明
     */
    private String roleDescription;

    /**
     * 创建时间
     */
    private String createTime;

    /**
     * 修改时间
     */
    private String updateTime;

    /**
     * 创建人
     */
    private Long createUser;

    /**
     * 修改人
     */
    private Long updateUser;

    public SysRoleListVo(SysRole sysRole) {
        this.id = sysRole.getId();
        this.roleName = sysRole.getRoleName();
        this.roleDescription = sysRole.getRoleDescription();
        this.createTime = sysRole.getCreateTime() == null ? "" : LocalDateTime.ofInstant(Instant.ofEpochMilli(sysRole.getCreateTime()), ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        this.updateTime = sysRole.getUpdateTime() == null ? "" : LocalDateTime.ofInstant(Instant.ofEpochMilli(sysRole.getUpdateTime()), ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        this.createUser = sysRole.getCreateUser();
        this.updateUser = sysRole.getUpdateUser();
    }
}